//引入类型
import type { responseData } from "./type";
import request from "../../../utils/request";
import type { data } from "../attr";

//属性管理模块接口
enum API {
  C1_URL = '/admin/product/getCategory1',
  C2_URL = '/admin/product/getCategory2/',
  C3_URL = '/admin/product/getCategory3/',
  ATTR_URL = '/admin/product/attrInfoList/',
  ADD_OR_MODIFY_URL = '/admin/product/saveAttrInfo/',
  DELETE_URL = '/admin/product/deleteAttr/'
}
//获取一级分类的接口
export const reqC1 = () => request.get<any, responseData>(API.C1_URL)
//获取二级分类的接口
export const reqC2 = (category1Id: number | string) => request.get<any, responseData>(API.C2_URL + category1Id)
//获取三级分类的接口
export const reqC3 = (category2Id: number | string) => request.get<any, responseData>(API.C3_URL + category2Id)
//获取属性的接口
export const reqAttr = (category1Id: number | string, category2Id: number | string, category3Id: number | string) => request.get<any, responseData>(API.ATTR_URL + `${category1Id}/${category2Id}/${category3Id}`)
//添加或修改属性
export const reqAddModify = (data: data) => request.post<any, any>(API.ADD_OR_MODIFY_URL, data)
//删除属性
export const reqDelete = (attrId: number | string) => request.delete<any, any>(API.DELETE_URL + attrId)